package org.iflytek.shiro;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ShiroApplication {

    public static void main(String[] args) {
        SpringApplication.run(ShiroApplication.class, args);
        Factory<SecurityManager> factory = new  IniSecurityManagerFactory("classpath:shiro.ini");
        SecurityManager securityManager=factory.getInstance();
        SecurityUtils.setSecurityManager(securityManager);
        Subject subject=SecurityUtils.getSubject();
        UsernamePasswordToken token=new UsernamePasswordToken(username:"admin",password:"root");
        try {
            subject.login(token);
            System.out.println("登陆成功！");
        }catch (AuthenticationException e) {
            e.printStackTrace();
        }
        subject.logout();
    }

}
